<?php
include('../../inc/global.inc');
$url=$_SERVER['HTTP_REFERER'];
?>
<?php
if($_POST['xg_act']){

	$c_rs=mysql_query("select * from catalog where id='$_POST[catalog_1]'");
	$c_row=mysql_fetch_array($c_rs);
	$c_rs2=mysql_query("select * from catalog  where id='$_POST[catalog_2]'");
	$c_row2=mysql_fetch_array($c_rs2);
	$c_rs3=mysql_query("select * from catalog where id='$_POST[catalog_3]'");
	$c_row3=mysql_fetch_array($c_rs3); 

$catalog_1=($_POST[catalog_1])?$_POST[catalog_1]:0;
$catalog_2=($_POST[catalog_2])?$_POST[catalog_2]:0;
$catalog_3=($_POST[catalog_3])?$_POST[catalog_3]:0;

$b_sh=($_POST[b_sh])?$_POST[b_sh]:0;
$b_tj=($_POST[b_tj])?$_POST[b_tj]:0;
  
  @mysql_query("update buy set b_title='$_POST[b_title]',catalog_id1='$catalog_1',catalog_1='$c_row[cat_name]',catalog_id2='$catalog_2',catalog_2='$c_row2[cat_name]',catalog_id3='$catalog_3',catalog_3='$c_row3[cat_name]',b_keyword='$_POST[b_keyword]',b_info='$_POST[b_info]',picture='$_POST[picture]',b_pinpai='$_POST[b_pinpai]',b_xinghao='$_POST[b_xinghao]',b_guige='$_POST[b_guige]',b_price='$_POST[b_price]',b_baozhuang='$_POST[b_baozhuang]',b_shuliang='$_POST[b_shuliang]',b_cailiao='$_POST[b_cailiao]',b_changdi='$_POST[b_changdi]',b_jhtime='$_POST[b_jhtime]',b_renzheng='$_POST[b_renzheng]',b_crz='$_POST[b_crz]',b_minorder='$_POST[b_minorder]',b_paytype='$_POST[b_paytype]',b_cl='1',b_sh='$b_sh',b_tj='$b_tj'  where id='".$_POST['iid']."'");


echo "<script>alert('Save is ok');location='".$_POST['urls']."';</script>";
}
?>
<HTML>
<HEAD>
<TITLE>Admin</TITLE>
<META http-equiv=Content-Type content="text/html; charset=utf-8">
<LINK href="../css/css.css" rel=stylesheet>
<script type='text/javascript' src="../js/islogin.js" charset="gb2312"></script>
<script type='text/javascript' src="../js/shijian.js"></script>
<script language="javascript" src="/member/js/catalog.js" type="text/javascript" charset="gb2312"></script>
</HEAD>
<BODY>
<center>
  <table width="780" border="0" cellpadding="0" cellspacing="1" bgcolor="#000000">
    <tr>
      <td height="25" bgcolor="#EEEEF9" style="padding-left:5px;">Buy信息&nbsp;&nbsp;<a href="javascript:history.go(-1)">返回</a></td>
    </tr>
  </table>
<?php
$rs=mysql_query("select * from buy where id='".$_GET['xg_id']."'");
$row=mysql_fetch_array($rs);
?>
<TABLE width="780" border="0" cellpadding="0" cellSpacing="1" bgcolor="#000000">
        <TBODY>
        <form method="post" action="" name="form1">
	 <tr>
        <td align="center" bgcolor="#8DA8CF" colspan="2" height="45"><strong>Buy信息</strong></td>
      </tr>
          <TR>
            <td width="17%" height="25" align="center" bgcolor="#eff6ff">求购产品名称</td>
            <TD width="83%" bgcolor="#F9F9F9" style="padding-left:4px;"><input name="b_title" value="<?=$row[b_title]?>" type="text" size="50" maxlength="250"></TD>
          </TR>
          <TR>
            <td height="25" align="center" bgcolor="#eff6ff">分类</td>
            <TD bgcolor="#F9F9F9" style="padding-left:4px;line-height:35px;"><select name="catalog_1" onChange="changelocation(document.form1.catalog_1.options[document.form1.catalog_1.selectedIndex].value)" >
	<option value="0">--一级分类--</option>   
  <?php
$rrs=mysql_query("select * from catalog where cat_id=0 order by cat_name asc");    
while($rrow=mysql_fetch_array($rrs)){   
  ?>     
   <option value="<?=$rrow[id]?>" <?php if($row[catalog_id1]==$rrow[id]){echo "selected";}?>><?=$rrow[cat_name]?></option>   
 <?php }?></select>&nbsp;<select name="catalog_2" onFocus="changelocation(document.form1.catalog_1.options[document.form1.catalog_1.selectedIndex].value)">
					  <option value="0">--二级分类--</option>
					  <?php 
					    $rrs2=mysql_query("select * from catalog where id='".$row['catalog_id2']."'");
						while($rrow2=mysql_fetch_array($rrs2)){
					  ?><option value="<?=$rrow2['id']?>" selected><?=$rrow2['cat_name']?></option>
					  <?php }?>
              </select>&nbsp;<select name="catalog_3" onFocus="changelocation2(document.form1.catalog_2.options[document.form1.catalog_2.selectedIndex].value)">   
                        <option   value="0"   selected>--三级分类--</option>
						<?php 
					    $rrs2=mysql_query("select * from catalog where id='".$row['catalog_id3']."'");
						while($rrow2=mysql_fetch_array($rrs2)){
					  ?><option value="<?=$rrow2['id']?>" selected><?=$rrow2['cat_name']?></option>
					  <?php }?>
              </select></TD>
          </TR>
          <TR>
            <td height="25" align="center" bgcolor="#eff6ff">关键字</td>
            <TD bgcolor="#F9F9F9" style="padding-left:4px;"><input name="b_keyword" value="<?=$row['b_keyword']?>"  type="text" size="40"></TD>
          </TR>		  
          <TR>
            <td height="25" align="center" bgcolor="#eff6ff">产品简介</td>
            <TD bgcolor="#F9F9F9" style="padding-left:4px;"><textarea name="b_info" cols="70" rows="20"><?=$row[b_info]?></textarea></TD>
          </TR>
          <TR>
            <td height="25" align="center" bgcolor="#eff6ff">求购产品图片</td>
            <TD bgcolor="#F9F9F9" style="padding-left:4px;"><?php if($row[picture]){?><img src="http://www.sandib2b.cn/upfile/<?=$row[picture]?>" width="140" height="104" border="0" /><br /><?php }?><input name="picture" type="text" size="35" value="<?=$row[picture]?>">
            &nbsp;&nbsp;<input name="button" type="button" onClick="window.open ('../upfile.php', 'newwindow', 'height=50, width=400, top=250, left=250, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no')" value="上传图片"></TD>
          </TR>
		  <TR>
            <td height="25" colspan="2" align="left" bgcolor="#8DA8CF" style="padding-left:10px;"><STRONG>产品属性</STRONG></td>
          </TR>
          <TR>
            <td height="25" align="center" bgcolor="#eff6ff">产品品牌</td>
            <TD bgcolor="#F9F9F9" style="padding-left:4px;"><input name="b_pinpai" value="<?=$row[b_pinpai]?>" type="text" size="30" maxlength="100"></TD>
          </TR>
          <TR>
            <td height="25" align="center" bgcolor="#eff6ff">产品型号</td>
            <TD bgcolor="#F9F9F9" style="padding-left:4px;"><input name="b_xinghao" value="<?=$row[b_xinghao]?>" type="text" size="30" maxlength="100"></TD>
          </TR>
          <TR>
            <td height="25" align="center" bgcolor="#eff6ff">产品规格</td>
            <TD bgcolor="#F9F9F9" style="padding-left:4px;"><input name="b_guige" value="<?=$row[b_guige]?>" type="text" size="30" maxlength="100"></TD>
          </TR>
          <TR>
            <td height="25" align="center" bgcolor="#eff6ff">产品价格</td>
            <TD bgcolor="#F9F9F9" style="padding-left:4px;"><input name="b_price" value="<?=$row[b_price]?>" type="text" size="30" maxlength="100"></TD>
          </TR>
          <TR>
            <td height="25" align="center" bgcolor="#eff6ff">产品包装</td>
            <TD bgcolor="#F9F9F9" style="padding-left:4px;"><input name="b_baozhuang" value="<?=$row[b_baozhuang]?>" type="text" size="30" maxlength="100"></TD>
          </TR>
          <TR>
            <td height="25" align="center" bgcolor="#eff6ff">产品材料</td>
            <TD bgcolor="#F9F9F9" style="padding-left:4px;"><input name="b_cailiao" value="<?=$row[b_cailiao]?>" type="text" size="30" maxlength="100"></TD>
          </TR>
          <TR>
            <td height="25" align="center" bgcolor="#eff6ff">产品产地</td>
            <TD bgcolor="#F9F9F9" style="padding-left:4px;"><input name="b_changdi" value="<?=$row[b_changdi]?>" type="text" size="30" maxlength="100"></TD>
          </TR>
          <TR>
            <td height="25" align="center" bgcolor="#eff6ff">产品交货期</td>
            <TD bgcolor="#F9F9F9" style="padding-left:4px;"><input name="b_jhtime" value="<?=$row[b_jhtime]?>" type="text" size="30" maxlength="250"></TD>
          </TR>
          <TR>
            <td height="25" align="center" bgcolor="#eff6ff">产品认证</td>
            <TD bgcolor="#F9F9F9" style="padding-left:4px;"><input name="b_renzheng" value="<?=$row[b_renzheng]?>" type="text" size="30" maxlength="100"></TD>
          </TR>
          <TR>
            <td height="25" align="center" bgcolor="#eff6ff">企业认证</td>
            <TD bgcolor="#F9F9F9" style="padding-left:4px;"><input name="b_crz" value="<?=$row[b_crz]?>" type="text" size="30" maxlength="250"></TD>
          </TR>
          <TR>
            <td height="25" align="center" bgcolor="#eff6ff">采购数量</td>
            <TD bgcolor="#F9F9F9" style="padding-left:4px;"><input name="b_minorder" value="<?=$row[b_minorder]?>" type="text" size="30" maxlength="100"></TD>
          </TR>
          <TR>
            <td height="25" align="center" bgcolor="#eff6ff">付款方式</td>
            <TD bgcolor="#F9F9F9" style="padding-left:4px;"><input name="b_paytype" type="text" value="<?=$row[b_paytype]?>" size="30" maxlength="100"></TD>
          </TR>
          <TR>
            <td height="25" align="center" bgcolor="#eff6ff">有效期</td>
            <TD bgcolor="#F9F9F9" style="padding-left:4px;"><?=date("Y-m-d",strtotime($row[b_addtime]))?>-<?=date("Y-m-d",strtotime($row[b_endtime]))?></TD>
          </TR>
	<TR>
        <td height="25" colspan="2" align="left" bgcolor="#8DA8CF" style="padding-left:10px;"><STRONG>管理员操作</STRONG></td>
     </TR>
	 <tr>
	   <td height="25" align="center" bgcolor="#eff6ff">审核通过</td>
	   <td bgcolor="#ffffff" style="padding-left:3px;"><input type="radio" name="b_sh" value="1" <?php if($row[b_sh]==1){echo "checked";}?>>是<input type="radio" name="b_sh" value="0" <?php if($row[b_sh]==0){echo "checked";}?>>否</td>
      </tr>
	 <tr>
	   <td height="25" align="center" bgcolor="#eff6ff">是否推荐</td>
	   <td bgcolor="#ffffff" style="padding-left:3px;"><input type="radio" name="p_tj" value="1" <?php if($row[b_tj]==1){echo "checked";}?>>是<input type="radio" name="b_tj" value="0" <?php if($row[b_tj]==0){echo "checked";}?>>否</td>
      </tr>
          <TR>
            <td height="25" align="center" bgcolor="#eff6ff">&nbsp;</td>
            <TD bgcolor="#F9F9F9" style="padding-left:4px;"><input type="submit" value=" 提交 ">
            <input type="hidden" name="iid" value="<?=$row['id']?>"><input type="hidden" name="urls" value="<?=$url?>"><input type="hidden" name="iid" value="<?=$row['id']?>">
        <INPUT type="hidden" value="ok" name="xg_act"></TD>
          </TR>
 </form>                
</TABLE>
</center>
</BODY>
</HTML>

